package cn.sinata.wanglin.aliyunoss;

import android.content.Context;
import com.alibaba.sdk.android.oss.ClientConfiguration;
import com.alibaba.sdk.android.oss.OSS;
import com.alibaba.sdk.android.oss.OSSClient;
import com.alibaba.sdk.android.oss.common.OSSLog;
import com.alibaba.sdk.android.oss.common.auth.OSSCredentialProvider;
import com.alibaba.sdk.android.oss.common.auth.OSSPlainTextAKSKCredentialProvider;
/**
 * description：
 * Created by kaihongwu on 2016/12/22 下午 9:31
 */
public  class OssMyUtils {
    public static OSS oss;
    // 需要配置以下字段为有效的值
    public static final String endpoint = "http://oss-cn-shenzhen.aliyuncs.com";
    public static final String accessKeyId = "ht8L1fbbPdlMGkbT";
    public static final String accessKeySecret = "QE9dutDJlVKPGKoQkxTewCCgM8WCfV";
    public static final String myBucket = "wanglin90";
    public static final String imgurlhead="http://wanglin90.oss-cn-shenzhen.aliyuncs.com/";//还回给服务器的地址拼接
    public  static void  init(Context context){
         OSSCredentialProvider credentialProvider = new OSSPlainTextAKSKCredentialProvider(accessKeyId, accessKeySecret);
         ClientConfiguration conf = new ClientConfiguration();
         conf.setConnectionTimeout(15 * 1000); // 连接超时，默认15秒
         conf.setSocketTimeout(15 * 1000); // socket超时，默认15秒
         conf.setMaxConcurrentRequest(10); // 最大并发请求书，默认5个
         conf.setMaxErrorRetry(1); // 失败后最大重试次数，默认2次
         OSSLog.enableLog();
         oss = new OSSClient(context, endpoint, credentialProvider, conf);
     }
}
